﻿@{
    Layout = "~/Views/Shared/_Form.cshtml";
}
@using Raffles.OA.Data;
@using Raffles.OA.Utility; 
<link href="~/Content/plugin/jquery.rating-stars/jquery.rating-stars.css" rel="stylesheet" />
<form id="form" class="form-horizontal m" role="form">
    <div class="form-group">
        <label class="col-sm-3 control-label ">项目名称</label>
        <div class="col-sm-9">
            <input id="name" name="Name" col="Name" type="text" class="form-control" disabled/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label ">销售名称</label>
        <div class="col-sm-9">
            <input id="saleManagerName" name="SaleManagerName" col="SaleManagerName" type="text" class="form-control" disabled />
        </div>
    </div>
    <div class="form-group price">
        <label class="col-sm-3 control-label ">操作率</label>
        <div class="col-sm-9">
            <input id="operateRate" name="OperateRate" col="OperateRate" type="number" class="form-control required" placeholder="请输入销售操作率" />
            <span class="help-block m-b-none text-red"><i class="fa fa-info-circle"></i> 小数对应百分比操作率,整数对应实际奖励金额</span>
        </div>
    </div>
</form> 
<script type="text/javascript">
    var projectId = frame.request("projectId"); 
    $(function () {
        getForm();
    });

    function getForm() {
        if (!!projectId) {
            frame.ajax({
                url: '@Url.Content("/Finance/Project/SetOperateRateForm")' + '?projectId=' + projectId,
                type: 'get',
                success: function (obj) {
                    if (obj.success) { 
                        $('#form').setWebControls(obj.data); 
                    }
                }
            });
        } 
    }

    function saveOperateRate(index) {
        if ($('#form').validate().form()) {
            var postData = $('#form').getWebControls({ projectId });
            frame.ajax({
                url: '@Url.Content("/Finance/Project/SaveOperateRateForm")',
                type: 'post',
                data: postData,
                success: function (obj) {
                    if (obj.success) {
                        frame.msgSuccess(obj.message);
                        parent.searchGrid();
                        parent.layer.close(index);
                    }
                    else {
                        frame.msgError(obj.message);
                    }
                }
            });
        }
    }
</script>

